import imghdr

from flask import current_app


def is_image(image):
    """
    校验文件是否为图片
    :param image: 待检验文件
    :return: bool值
    """
    try:
        file_type = imghdr.what(image)
    except Exception as e:
        current_app.logger.info(e)
        return False
    else:
        if not file_type:
            return False
        else:
            return True
